﻿@model SearchModel
@{
    Layout = "~/Views/Shared/_ColumnsThree.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Search").Text);
}
@using Nop.Core;
@using Nop.Core.Infrastructure;
@using Nop.Web;
@using Nop.Web.Framework;
@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
@using Nop.Web.Extensions;
<script type="text/javascript">
    $(document).ready(function () {

        $("#@Html.FieldIdFor(model => model.As)").click(toggleAdvancedSearch);

        toggleAdvancedSearch();
    });

    function toggleAdvancedSearch() {

        if ($('#@Html.FieldIdFor(model => model.As)').is(':checked')) {
            $('#pnl-advanced-search').show();
        }
        else {
            $('#pnl-advanced-search').hide();
        }
    }

</script>
<div class="search-panel">
    @using (Html.BeginRouteForm("ProductSearch", FormMethod.Get))
    {
        <div class="page-title">
            <h1>@T("Search")</h1>
        </div>
        <div class="clear">
        </div>
        <div class="search-input">
            <table class="basic-search">
                <tbody>
                    <tr>
                        <td class="title">
                            @Html.LabelFor(model => model.Q):
                        </td>
                        <td class="data">
                            @Html.TextBoxFor(model => model.Q, new { @class = "searchtext" })
                        </td>
                    </tr>
                @Html.Action("WidgetsByZone", "Widget", new { widgetZone = "productsearch_page_basic" })
                    <tr>
                        <td class="title" colspan="2">
                            @Html.CheckBoxFor(model => model.As)
                            @Html.LabelFor(model => model.As)
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <table class="adv-search" id="pnl-advanced-search">
                                <tbody>
                                    @if (Model.AvailableCategories.Count > 0)
                                    {
                                        <tr>
                                            <td class="title">
                                                @Html.LabelFor(model => model.Cid):
                                            </td>
                                            <td class="data">
                                                @Html.DropDownListFor(model => model.Cid, Model.AvailableCategories)
                                            </td>
                                        </tr>
                                    <tr>
                                        <td class="data" colspan="2">
                                            @Html.CheckBoxFor(model => model.Isc)
                                            @Html.LabelFor(model => model.Isc)
                                        </td>
                                    </tr>
                                    }
                                    @if (Model.AvailableManufacturers.Count > 0)
                                    {
                                        <tr>
                                            <td class="title">
                                                @Html.LabelFor(model => model.Mid):
                                            </td>
                                            <td class="data">
                                                @Html.DropDownListFor(model => model.Mid, Model.AvailableManufacturers)
                                            </td>
                                        </tr>
                                    }
                                    <tr>
                                        <td class="title">
                                            @T("Search.PriceRange"):
                                        </td>
                                        <td class="data">
                                            @T("Search.PriceRange.From")
                                        @Html.TextBoxFor(model => model.Pf, new { @class = "price-from" })
                                            @T("Search.PriceRange.To")
                                        @Html.TextBoxFor(model => model.Pt, new { @class = "price-to" })
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="data" colspan="2">
                                            @Html.CheckBoxFor(model => model.Sid)
                                            @Html.LabelFor(model => model.Sid)
                                        </td>
                                    </tr>
                                @Html.Action("WidgetsByZone", "Widget", new { widgetZone = "productsearch_page_advanced" })
                                </tbody>
                            </table>
                        </td>
                    </tr>
                    <tr>
                    <td colspan="2" class="buttons">
                                <input type="submit" id="btnsearch" name="btnsearch" class="searchbutton" value="@T("Search")" />
                        </td>
                    </tr>
                    @if (!String.IsNullOrEmpty(Model.Warning))
                    {
                        <tr>
                            <td colspan="2">
                            <span class="warning">
                                    @Model.Warning
                            </span>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
        <div class="clear">
        </div>
        <div class="search-results">
        @if (Model.NoResults)
        {
            <span class="result">
                @T("Search.NoResultsText")
            </span>
        }
            <div class="product-grid">
                @(Html.DataList<ProductOverviewModel>(Model.Products, 3,
                            @<div class="item-box">
                                @Html.Partial("_ProductBox", @item)
                            </div>
                        ))
            </div>
            <div class="clear">
            </div>
            <div class="pager">
            @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber").BooleanParameterName("as").BooleanParameterName("isc").BooleanParameterName("sid")
            </div>
        </div>
    }
</div>
